_Pragma("once");

#include <cstdint>
#include <sstream>

/**
 * 下位机交互状态统计类
 * @author lizb
 */

struct DeviceStatisticInfo {

    void checkSuccess() {
        ++checkSuccessTimes;
        continuousCheckFailTimes = 0;
        continuousInteractionFailTimes = 0;
    }

    void checkFail() {
        ++checkFailTimes;
        ++continuousCheckFailTimes;
    }


    void setCheckStatus(const bool result) {
        if (result) {
            checkSuccess();
        } else {
            checkFail();
        }
    }


    void setInteractionStatus(const bool result) {
        if (result) {
            interactionSuccess();
        } else {
            interactionFail();
        }
    }


    void interactionFail() {
        ++interactionFailTimes;
        ++continuousInteractionFailTimes;
    }


    void interactionSuccess() {
        ++interactionSuccessTimes;
        continuousInteractionFailTimes = 0;
    }

    /**
     * 告警阈值
     */
    int alarmThreshold = 3;

    /**
      * 确认成功次数
      */
    int32_t checkSuccessTimes;
    /**
     * 确认失败次数
     */
    int32_t checkFailTimes;
    /**
     * 连续确认失败次数
     */
    int32_t continuousCheckFailTimes;
    /**
     * 交互成功次数
     */
    int32_t interactionSuccessTimes;
    /**
     * 交互失败次数
     */
    int32_t interactionFailTimes;
    /**
     * 连续交互失败次数
     */
    int32_t continuousInteractionFailTimes;


};
